<? $page_title='更改供应商' ?>
<? include "FASHION/page_header.phtml" ?>

<{if $indent.back_flow == 1}>
	<div class="notice">
		已有材料入库，原订单将被关闭
	</div>
	<table border="0" cellpadding="4" cellspacing="0" width="100%"><tbody>
	<tr>
		<td width="80" valign="top">供应商：</td>
		<td valign="top"><? $indent.supplier ?></td>
		<td width="15%" class="right">PO NO.：</td>
		<td width="35%"><? $indent.sno ?></td>
	</tr>
	</table>
	<table border="0" class="list"><tbody>
	<tr class="nobg">
		<th>编号</th>
		<th>材料名称</th>
		<th>品牌</th>
		<th>规格</th>
		<th>单位</th>
		<th width="60">入库数量</th>
		<th>单价</th>
		<th>金额</th>
		<th>备注</th>
	</tr>
	<{foreach item=ware from=$indent.items}>
		<{if $ware.amount_back>0}>
			<tr>
				<td><{$ware.sno}></td>
				<td><{$ware.name}></td>
				<td><{$ware.brand}></td>
				<td><{$ware.specific}></td>
				<td><{$ware.unit}></td>
				<td><div class="decimal"><{$ware.amount_back}></div></td>
				<td><div class="decimal fnum"><{$ware.price}></div></td>
				<td><div class="decimal fnum"><{= $ware.price * $ware.amount_back}></div></td>
				<td><div class="text"><{= $ware.remark}></div></td>
			</tr>
		<{/if}>
	<{/foreach}>
	</tbody></table>

	<br/>
	<div class="notice">
		如下材料计入新订单
	</div>
<{else}>
	<table border="0" cellpadding="4" cellspacing="0" width="100%">
	<tr>
		<td width="80" valign="top">原供应商：</td>
		<td valign="top"><? $indent.supplier ?></td>
		<td width="15%" class="right">PO NO.：</td>
		<td width="35%"><? $indent.sno ?></td>
	</tr>
	</table>
<{/if}>


<form method="post">
<table border="0" class="list"><tbody>
	<tr class="nobg"><td colspan="20" style="text-align:left">
		<b>供应商:</b>
		<{foreach item=sp from=$all_suppliers}>
		<input type="checkbox" name="sspid[]" value="<{$sp.id}>" id="spid_<{$sp.id}>" <{if in_array($sp.id, $sspids) }>checked<{/if}> 
			   /><label for="spid_<{$sp.id}>"><{$sp.name}></label> &nbsp;
		<{/foreach}>
		<input type="submit" value="选择" class="button" />
	</td></tr>

	<tr class="nobg">
		<th rowspan="2">编号</th>
		<th rowspan="2">材料名称</th>
		<th rowspan="2">品牌</th>
		<th rowspan="2">规格</th>
		<th rowspan="2">单位</th>
		<th rowspan="2">数量</th>
		<{foreach item=s from=$suppliers}>
			<th colspan="2"><{$s.name}></th>
		<{/foreach}>
	</tr>
	<tr class="nobg">
		<{foreach item=s from=$suppliers}>
			<th>单价</th>
			<th>金額</th>
		<{/foreach}>
	</tr>

	<{foreach item=ware from=$itemsdiff}>
		<{if $ware.amount_diff>0}>
			<tr>
				<td><{$ware.sno}></td>
				<td><{$ware.name}></td>
				<td><{$ware.brand}></td>
				<td><{$ware.specific}></td>
				<td><{$ware.unit}></td>
				<td><div class="decimal"><{$ware.amount_diff}></div></td>
			<{foreach item=sp from=$suppliers}>
				<td><div class="decimal fnum sp_<{$sp.id}> price"><{$ware.suppliers[$sp.id].quote }></div></td>
				<td><div class="decimal fnum sp_<{$sp.id}>"><?= $ware.suppliers[$sp.id].quote * $ware.amount ?></div></td>
			<{/foreach}>
			</tr>
		<{/if}>
	<{/foreach}>
</tbody></table>
</form>

<br/>
<form id="form2" method="post" action="<? url('indft-dochgsup') ?>">
<table class="select">
	<tr class="nobg">
		<td width="150">新供应商： &nbsp; </td>
		<td align="left"><?= Html::options2(array(
						'data' => $suppliers,
						'name' => 'supplier_id',
						'id' => 'supplier_id',
						'val_key' => 'id',
						'text_key' => 'name',
						'tips' => '',
						'ext' => "onfocus=\"$(this).children('option[value={$indent['supplier_id']}]').attr('disabled',true)\"",
					)) ?></td>
	</tr>
	<tr class="nobg">
		<td>PR NO. ： &nbsp; </td>
		<td align="left"><input type="text" name="pr_no" value="<{$indent.pr_no}>" /></td>
	</tr>
	<tr class="nobg">
		<td class="nowrap">特殊说明： &nbsp; </td>
		<td style="text-align:left">
			<textarea style="width:90%;" rows="3" name="remark"><? $indent.remark ?></textarea>
		</td>
	</tr>
</table>
<br/>
<div class="center">
	<INPUT TYPE="button" class="button" value="返回" onclick="g2('<? url("indft/id/{$indent['id']}") ?>')"> &nbsp;
	<INPUT TYPE="submit" class="button" value="保存更改" />
</div>
<input type="hidden" name="id" value="<{ $indent['id'] }>" />
<{foreach item=ware from=$itemsdiff}><{if $ware.amount_diff>0}>
	<{//新订单的材料及数量}>
	<input type="hidden" name="amount[<{ $ware.ware_id }>]" value="<{ $ware.amount_diff }>" />
<{/if}><{/foreach}>

<{if $indent.back_flow==1}><{foreach item=ware from=$indent.items}><{if $ware.amount_back>0}>
	<{//需要关闭的订单材料及数量}>
	<input type="hidden" name="itemoff[<{$ware.ware_id}>]" value="<{$ware.amount_back}>" />
<{/if}><{/foreach}><{/if}>
</form>

<script>
ajax_form({id : 'form2',before:function(){ return chkSupplierInfo() && confirm('确认提交信息吗？');}});
    function chkSupplierInfo(){
		var full = 1;
		$(".sp_"+$('#supplier_id').val()).filter('.price').each(function(){
			if(!$(this).html()){ full = 0; }
		});
		if(!full){
			alert("供应商报价信息不全");
			return false;
		}
		return true;
	}
</script>

<?include "FASHION/page_footer.phtml"?>
